package com.gaoyi.crm.repository;

import com.gaoyi.crm.callback.Callback;
import com.gaoyi.crm.callback.OnResultListener;
import com.gaoyi.crm.util.OKHttpUtil;

import java.lang.reflect.Type;

public class SyncRepository {
    public void syncDownload(Object bean, final OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postSyncThread(OKHttpUtil.NET_URL + "/api/syns/client/syn", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                }, typeofT);
    }

    public void syncUpload(Object bean, final OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/Syns/server/syn", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                }, typeofT);
    }
}
